﻿using System;
using System.Windows.Media.Media3D;
using Perspective.Wpf3D.Primitives;
using Perspective.Wpf3D.Sculptors;
using System.Windows;

namespace Perspective.Wpf3D.Shapes
{
    // <summary>
    /// 凹多边形
    /// A 3D flat concave polygon element.
    /// Default radius is 1.0.
    /// </summary>
    public class ConcavePolygon3D : ConcaveElement3D
    {
        #region Constructors
        /// <summary>
        /// Initializes a new instance of ConcavePolygon3D.
        /// </summary>
        public ConcavePolygon3D()
        {
        }
        #endregion

        #region Properties

        #region CircumRadius 外接圆半径
        /// <summary>
        /// 外接圆半径
        /// Gets or sets the concave polygon circumcircle radius.
        /// Default value is 1.0.
        /// </summary>
        public double CircumRadius
        {
            get { return (double)GetValue(CircumRadiusProperty); }
            set { SetValue(CircumRadiusProperty, value); }
        }

        /// <summary>
        /// Identifies the circumcircle radius dependency property.
        /// </summary>
        public static readonly DependencyProperty CircumRadiusProperty =
            DependencyProperty.Register(
                "CircumRadius",
                typeof(double),
                typeof(ConcavePolygon3D),
                new UIPropertyMetadata(
                    ConcavePolygonSculptor.DefaultCircumcircleRadius,
                    VisualPropertyChanged),
                    PositiveDoubleValidateValue);
        #endregion

        #endregion


        /// <summary>
        /// Called by UIElement3D.InvalidateModel() to update the 3D model.
        /// </summary>
        protected override void OnUpdateModel()
        {
            Sculptor = new ConcavePolygonSculptor(CircumRadius,BranchCount,InitialAngle,ConcaveRadius);

            base.OnUpdateModel();
        }
    }
}
